﻿using System.Windows;
using FM.Views;
using FM.录音.Services;
using FM.录音.Views;
using FM.录音.接口;
using FM.接口;
using Microsoft.Practices.Prism.Logging;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Mvvm;
using Microsoft.Practices.Prism.UnityExtensions;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Practices.Unity;

namespace FM.录音
{
    public class 启动器 : UnityBootstrapper
    {
        protected override DependencyObject CreateShell()
        {
            var 视图1 = ServiceLocator.Current.GetInstance<主窗口>();
            return 视图1;
        }

        protected override void InitializeShell()
        {
            base.InitializeShell();
            Application.Current.MainWindow = (Window) Shell;
            var view = Shell as IView;
            if (view != null)
            {
                view.LoadViewModel();
            }
            Application.Current.MainWindow.Show();
        }

        protected override IModuleCatalog CreateModuleCatalog()
        {
            var 模块管理中心 = new ModuleCatalog();
            return 模块管理中心;
        }

        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();
            Container.RegisterType<ILoggerFacade, NLog日志>(new ContainerControlledLifetimeManager());
            Container.RegisterType<I系统配置服务, 系统配置服务1>(new ContainerControlledLifetimeManager());
            Container.RegisterType<I倒计时, 倒计时窗口>();
            Container.RegisterType<I监听服务, 监听服务1>();
            Container.RegisterType<I监视服务, 监视服务1>();

            Container.RegisterType<I录音服务, 录音服务wav>("wav");
            Container.RegisterType<I录音服务, 录音服务mp3>("mp3");
            Container.RegisterType<选项窗口>(new ContainerControlledLifetimeManager());
        }

        protected override void ConfigureModuleCatalog()
        {
            base.ConfigureModuleCatalog();
            小冰.Set默认解析器();
            var moduleCatalog = (ModuleCatalog) ModuleCatalog;
            moduleCatalog.AddModule(typeof (启动模块));
        }
    }
}